package com.cnap.multiclouldmgmt.model.scale.policy;

import com.cnap.multiclouldmgmt.model.scale.db.ScalingPolicyPO;
import com.cnap.multiclouldmgmt.model.scale.validator.EnumCheck;

import javax.validation.constraints.NotNull;

/**
 * <类文件描述>
 *
 * @author xc
 **/
public class ScalingPolicyDTO {
    // 伸缩组的id
    @NotNull(message = "伸缩组信息不能为空")
    private String groupId;
    // 监控周期
    private int duration;
    // 连续出现的次数
    private int continuousNum;
    // 冷却时间（秒）
    private int coolTime;
    // 执行动作类型
    @EnumCheck(enumClass = ScalingPolicyTypeEnum.class, message = "执行动作类型错误")
    private String type;
    // 执行动作数量
    private int num;
    // 触发条件-资源
    @EnumCheck(enumClass = ScalingPolicyResourceEnum.class, message = "触发资源错误")
    private String resource;
    // 触发条件-值
    private int value;

    /**
     * get
     *
     * @return GroupId
     */
    public String getGroupId() {
        return groupId;
    }

    /**
     * set
     *
     * @param groupId groupId
     */
    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    /**
     * get
     *
     * @return Duration
     */
    public int getDuration() {
        return duration;
    }

    /**
     * set
     *
     * @param duration duration
     */
    public void setDuration(int duration) {
        this.duration = duration;
    }

    /**
     * get
     *
     * @return ContinuousNum
     */
    public int getContinuousNum() {
        return continuousNum;
    }

    /**
     * set
     *
     * @param continuousNum continuousNum
     */
    public void setContinuousNum(int continuousNum) {
        this.continuousNum = continuousNum;
    }

    /**
     * get
     *
     * @return CoolTime
     */
    public int getCoolTime() {
        return coolTime;
    }

    /**
     * set
     *
     * @param coolTime coolTime
     */
    public void setCoolTime(int coolTime) {
        this.coolTime = coolTime;
    }

    /**
     * get
     *
     * @return Type
     */
    public String getType() {
        return type;
    }

    /**
     * set
     *
     * @param type type
     */
    public void setType(String type) {
        this.type = type;
    }

    /**
     * get
     *
     * @return Num
     */
    public int getNum() {
        return num;
    }

    /**
     * set
     *
     * @param num num
     */
    public void setNum(int num) {
        this.num = num;
    }

    /**
     * get
     *
     * @return Resource
     */
    public String getResource() {
        return resource;
    }

    /**
     * set
     *
     * @param resource resource
     */
    public void setResource(String resource) {
        this.resource = resource;
    }

    /**
     * get
     *
     * @return Value
     */
    public int getValue() {
        return value;
    }

    /**
     * set
     *
     * @param value value
     */
    public void setValue(int value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return "ScalingPolicyDTO{" +
                "groupId='" + groupId + '\'' +
                ", duration=" + duration +
                ", continuousNum=" + continuousNum +
                ", coolTime=" + coolTime +
                ", type='" + type + '\'' +
                ", num=" + num +
                ", resource='" + resource + '\'' +
                ", value=" + value +
                '}';
    }

    /**
     * 转换成po
     *
     * @return po
     */
    public ScalingPolicyPO toPOWithoutId() {
        ScalingPolicyPO po = new ScalingPolicyPO();
        po.setValue(value);
        po.setResource(resource);
        // 策略id与伸缩组id相同
        po.setGroupId(groupId);
        po.setDuration(duration);
        po.setCoolTime(coolTime);
        po.setContinuousNum(continuousNum);
        po.setNum(num);
        po.setType(type);

        return po;
    }
}
